﻿<UserControl x:Class="Microsoft.Research.ScientificWorkflow.WebClient.Views.WorkflowApplication.NavigationView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" 
    Width="Auto" Height="Auto" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" 
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" 
    xmlns:treeTemplate="clr-namespace:System.Windows;assembly=System.Windows.Controls"
    Margin="5,5,0,5">
    <UserControl.Resources>
        <Style x:Key="TreeViewItemStyle1" TargetType="controls:TreeViewItem">
            <Setter Property="Padding" Value="3"/>
            <Setter Property="HorizontalContentAlignment" Value="Left"/>
            <Setter Property="VerticalContentAlignment" Value="Top"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Cursor" Value="Arrow"/>
            <Setter Property="IsTabStop" Value="True"/>
            <Setter Property="TabNavigation" Value="Once"/>
            <Setter Property="IsExpanded" Value="True"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="controls:TreeViewItem">
                        <Grid Background="{x:Null}">
                            <vsm:VisualStateManager.VisualStateGroups>
                                <vsm:VisualStateGroup x:Name="CommonStates">
                                    <vsm:VisualState x:Name="Normal"/>
                                    <vsm:VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Header" Storyboard.TargetProperty="Foreground">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <SolidColorBrush Color="#FF999999"/>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </vsm:VisualState>
                                </vsm:VisualStateGroup>
                                <vsm:VisualStateGroup x:Name="SelectionStates">
                                    <vsm:VisualState x:Name="Unselected"/>
                                    <vsm:VisualState x:Name="Selected">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="select" Storyboard.TargetProperty="Opacity" To=".75"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="SelectedInactive">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="inactive" Storyboard.TargetProperty="Opacity" To=".2"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                </vsm:VisualStateGroup>
                                <vsm:VisualStateGroup x:Name="HasItemsStates">
                                    <vsm:VisualState x:Name="HasItems"/>
                                    <vsm:VisualState x:Name="NoItems">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpanderButton" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </vsm:VisualState>
                                </vsm:VisualStateGroup>
                                <vsm:VisualStateGroup x:Name="ExpansionStates">
                                    <vsm:VisualState x:Name="Collapsed"/>
                                    <vsm:VisualState x:Name="Expanded">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ItemsHost" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </vsm:VisualState>
                                </vsm:VisualStateGroup>
                            </vsm:VisualStateManager.VisualStateGroups>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="15"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <ToggleButton HorizontalAlignment="Stretch" x:Name="ExpanderButton" VerticalAlignment="Stretch" IsTabStop="False" TabNavigation="Once">
                                <ToggleButton.Template>
                                    <ControlTemplate TargetType="ToggleButton">
                                        <Grid x:Name="Root" Background="Transparent">
                                            <vsm:VisualStateManager.VisualStateGroups>
                                                <vsm:VisualStateGroup x:Name="CommonStates">
                                                    <vsm:VisualState x:Name="Normal"/>
                                                    <vsm:VisualState x:Name="MouseOver">
                                                        <Storyboard>
                                                            <ColorAnimation Duration="0" Storyboard.TargetName="UncheckedVisual" Storyboard.TargetProperty="(Path.Stroke).Color" To="#FF1BBBFA"/>
                                                        </Storyboard>
                                                    </vsm:VisualState>
                                                    <vsm:VisualState x:Name="Disabled">
                                                        <Storyboard>
                                                            <DoubleAnimation Duration="0" Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To=".7"/>
                                                        </Storyboard>
                                                    </vsm:VisualState>
                                                </vsm:VisualStateGroup>
                                                <vsm:VisualStateGroup x:Name="CheckStates">
                                                    <vsm:VisualState x:Name="Unchecked"/>
                                                    <vsm:VisualState x:Name="Checked">
                                                        <Storyboard>
                                                            <DoubleAnimation Duration="0" Storyboard.TargetName="UncheckedVisual" Storyboard.TargetProperty="Opacity" To="0"/>
                                                            <DoubleAnimation Duration="0" Storyboard.TargetName="CheckedVisual" Storyboard.TargetProperty="Opacity" To="1"/>
                                                        </Storyboard>
                                                    </vsm:VisualState>
                                                </vsm:VisualStateGroup>
                                            </vsm:VisualStateManager.VisualStateGroups>
                                            <Grid HorizontalAlignment="Right" Margin="2 2 5 2">
                                                <Path Height="9" HorizontalAlignment="Right" x:Name="UncheckedVisual" VerticalAlignment="Center" Width="6" Fill="#FFFFFFFF" Stroke="#FF989898" StrokeLineJoin="Miter" StrokeThickness="1" Data="M 0,0 L 0,9 L 5,4.5 Z"/>
                                                <Path Height="6" HorizontalAlignment="Center" x:Name="CheckedVisual" VerticalAlignment="Center" Width="6" Opacity="0" Fill="#FF262626" StrokeLineJoin="Miter" Data="M 6,0 L 6,6 L 0,6 Z"/>
                                            </Grid>
                                        </Grid>
                                    </ControlTemplate>
                                </ToggleButton.Template>
                            </ToggleButton>
                            <Rectangle x:Name="select" IsHitTestVisible="False" Opacity="0" Grid.Column="1" Fill="#FFBADDE9" Stroke="#FF6DBDD1" StrokeThickness="1" RadiusX="2" RadiusY="2"/>
                            <Rectangle x:Name="inactive" IsHitTestVisible="False" Opacity="0" Grid.Column="1" Fill="#FF999999" Stroke="#FF333333" StrokeThickness="1" RadiusX="2" RadiusY="2"/>
                            <Button Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" x:Name="Header" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" IsTabStop="False" TabNavigation="Once" Grid.Column="1" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" ClickMode="Hover">
                                <Button.Template>
                                    <ControlTemplate TargetType="Button">
                                        <Grid Background="{TemplateBinding Background}">
                                            <vsm:VisualStateManager.VisualStateGroups>
                                                <vsm:VisualStateGroup x:Name="CommonStates">
                                                    <vsm:VisualState x:Name="Normal"/>
                                                    <vsm:VisualState x:Name="Pressed">
                                                        <Storyboard>
                                                            <DoubleAnimation Duration="0" Storyboard.TargetName="hover" Storyboard.TargetProperty="Opacity" To=".5"/>
                                                        </Storyboard>
                                                    </vsm:VisualState>
                                                    <vsm:VisualState x:Name="Disabled">
                                                        <Storyboard>
                                                            <DoubleAnimation Duration="0" Storyboard.TargetName="content" Storyboard.TargetProperty="Opacity" To=".55"/>
                                                        </Storyboard>
                                                    </vsm:VisualState>
                                                </vsm:VisualStateGroup>
                                            </vsm:VisualStateManager.VisualStateGroups>
                                            <Rectangle x:Name="hover" IsHitTestVisible="False" Opacity="0" Fill="#FFBADDE9" Stroke="#FF6DBDD1" StrokeThickness="1" RadiusX="2" RadiusY="2"/>
                                            <ContentPresenter Cursor="{TemplateBinding Cursor}" HorizontalAlignment="Left" Margin="{TemplateBinding Padding}" x:Name="content" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                                        </Grid>
                                    </ControlTemplate>
                                </Button.Template>
                            </Button>
                            <ItemsPresenter x:Name="ItemsHost" Visibility="Collapsed" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="TreeViewStyle1" TargetType="controls:TreeView">
            <Setter Property="Background" Value="#FFFFFFFF"/>
            <Setter Property="Foreground" Value="#FF000000"/>
            <Setter Property="HorizontalContentAlignment" Value="Left"/>
            <Setter Property="VerticalContentAlignment" Value="Top"/>
            <Setter Property="Cursor" Value="Arrow"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Padding" Value="1"/>
            <Setter Property="BorderBrush">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFA3AEB9" Offset="0"/>
                        <GradientStop Color="#FF8399A9" Offset="0.375"/>
                        <GradientStop Color="#FF718597" Offset="0.375"/>
                        <GradientStop Color="#FF617584" Offset="1"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="IsTabStop" Value="True"/>
            <Setter Property="TabNavigation" Value="Once"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="controls:TreeView">
                        <Grid x:Name="Root">
                            <Grid.Resources>
                                <SolidColorBrush x:Key="BorderBrush" Color="#FF000000"/>
                            </Grid.Resources>
                            <Border x:Name="Border" BorderBrush="{x:Null}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2">
                                <Border Margin="1" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}">
                                    <ScrollViewer Background="{x:Null}" BorderBrush="Transparent" BorderThickness="0" IsTabStop="False" TabNavigation="Once" x:Name="ScrollViewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                                        <ItemsPresenter Margin="5" x:Name="TreeItems"/>
                                    </ScrollViewer>
                                </Border>
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
        <treeTemplate:HierarchicalDataTemplate x:Key="ParentActivityTemplate" ItemsSource="{Binding Path=Children}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="21.5"/>
                    <ColumnDefinition Width="*" MinWidth="26.098"/>
                </Grid.ColumnDefinitions>
                <Image Grid.ColumnSpan="1" Width="16" HorizontalAlignment="Center" VerticalAlignment="Center" Height="16">
                    <Image.Source>
                        <Binding Path="ItemIcon"/>
                    </Image.Source>
                </Image>
                <TextBlock Grid.Column="1" Margin="1,0,0,0" Text="{Binding Path=Label}"/>
            </Grid>
        </treeTemplate:HierarchicalDataTemplate>
        
    </UserControl.Resources>
	<Border Height="Auto" BorderBrush="#FFE0E0E0" BorderThickness="1,1,1,1" CornerRadius="5,5,5,5" Width="Auto">
		<Grid>
			<Grid.RowDefinitions>
				<RowDefinition Height="28.16"/>
				<RowDefinition Height="*"/>
			</Grid.RowDefinitions>
			<Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0" CornerRadius="5,5,0,0">
				<Border.Background>
					<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
						<GradientStop Color="#FFFBFBFB" Offset="0"/>
						<GradientStop Color="#FFEBEBEB" Offset="1"/>
					</LinearGradientBrush>
				</Border.Background>
				<TextBlock Margin="8,3,0,0" TextWrapping="Wrap" FontFamily="./Fonts/Fonts.zip#Segoe UI" FontWeight="Normal" FontSize="12" d:IsStaticText="True"><Run FontSize="14" Text="Workflows"/></TextBlock>
			</Border>
			<Grid Margin="5,5,0,5" Grid.Row="1">
				<Grid.RowDefinitions>
					<RowDefinition Height="*"/>
				</Grid.RowDefinitions>
				<ScrollViewer HorizontalAlignment="Stretch" Grid.Row="0" BorderBrush="{x:Null}" VerticalScrollBarVisibility="Auto" Padding="0,0,0,0">
					<controls:TreeView x:Name="treeView" HorizontalAlignment="Stretch" BorderBrush="{x:Null}" Style="{StaticResource TreeViewStyle1}" ItemTemplate="{StaticResource ParentActivityTemplate}" ItemContainerStyle="{StaticResource TreeViewItemStyle1}">
                    </controls:TreeView>
				</ScrollViewer>
			</Grid>
		</Grid>
	</Border>
    	
</UserControl>
